package com.dong.common;

import java.io.Serializable;


public class Result<T> implements Serializable {
    private static final long serialVersionUID = -52601052307228630L;
    private final static Integer SUCCESS_CODE = 200;
    private final static Integer ERROR_CODE = 500;
    private final static String SUCCESS_MSG = "success";
    private final static String ERROR_MSG = "ERROR";

    private Integer code;
    private String msg;
    private T data;

    private Result() {
    }

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> Result<T> success() {
        return success(null);
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(SUCCESS_CODE, SUCCESS_MSG, data);
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public T getData() {
        return data;
    }
}
